#include "RL_PCF8574T.h"


PCF8574 pcf8574(0x20);//默认I2C地址为0X27

void setup()
{
	Serial.begin(9600);
	delay(1000);


  for(int i=0;i<8;i++)
	pcf8574.pinMode(i, INPUT);
	
	Serial.print("Init pcf8574...");
	if (pcf8574.begin()){
		Serial.println("OK");
	}else{
		Serial.println("KO");
	}
}

void loop()
{
	uint8_t val = pcf8574.digitalRead(P0);//获取P0端口数值
	if (val==HIGH) Serial.println("BLACK");
 else Serial.println("WHITE");
  	delay(50);

  /*  PCF8574::DigitalInput di = pcf8574.digitalReadAll();//获取全部端口数值
    Serial.print("Read ALL ");
    Serial.print(di.p0);
    Serial.print(" - ");
    Serial.print(di.p1);
    Serial.print(" - ");
    Serial.print(di.p2);
    Serial.print(" - ");
    Serial.print(di.p3);
    Serial.print(" - ");
    Serial.print(di.p4);
    Serial.print(" - ");
    Serial.print(di.p5);
    Serial.print(" - ");
    Serial.print(di.p6);
    Serial.print(" - ");
    Serial.println(di.p7);*/

  
}
